# !/usr/bin/env python
# -*- coding: utf-8 -*-


def jaccard_similarity(set1, set2):
    intersection_cardinality = len(set1.intersection(set2))
    union_cardinality = len(set1.union(set2))
    return intersection_cardinality / union_cardinality


# 示例使用
set1 = {'a', 'b', 'c'}
set2 = {'b', 'c', 'd'}

if __name__ == '__main__':
    similarity = jaccard_similarity(set1, set2)
    print(similarity)  # 输出相似度
